import logging
import logging.config
import configparser
import os
curpath = os.path.dirname(os.path.realpath(__file__))
cfgpath = os.path.join(curpath, "config.ini")
conf_log = os.path.join(curpath, "log_config.ini")


def getConfig():
    cfg = configparser.ConfigParser()
    cfg.read(cfgpath, encoding="utf-8")
    return cfg


def get_logger(name='root'):
    logging.config.fileConfig(conf_log)
    return logging.getLogger(name)


logger = get_logger(__name__)


if __name__ == "__main__":
    cfg = getConfig()
    print(cfg.get("mysql", "host"))
